<#import "../system.ftl" as sys />
<style type="text/css">
.module-add{
	display:none;
}
.module-add .loadingext{
	text-align:center;
}
.module-add .extname{
	cursor:pointer;
	font-weight:bold;
}
.modulelist{
	margin:20px 0px;
}
.modulelist table{
	margin-top:20px;
}
.modulelist .mtitle{
	cursor:pointer;
	color:#09d;
}
</style>
<script type="text/javascript">
$(document).ready(function(e) {
	dialog('.module-add',{
		autoOpen:false,
		modal:true,
		resizable:false,
		title:'添加模板文件',
		width:400
	});
});
function module_add(){
	$('.module-add').load('system/module.action?act=add&type=extlist');
	$('.module-add').dialog('open');
}
function module_edit(){
	var idcb=$('.modulelist input[name=mid]:checked');
	if(idcb.length==0){
		alert('请选择要编辑的内容！');
	}else if(idcb.length>1){
		alert('一次只能编辑一个，请重新选择！');
	}else{
		goPage('system/module.action?act=edit&id='+idcb.val(),'.main');
	}
}
function createModule(extkey){
	$('.module-add').dialog('close');
	goPage('system/module.action?act=add&key='+extkey,'#main')
}
function module_delete() {
	var gid = serializeArray($('.modulelist input[name=id]:checked'));
	if (gid.length == 0) {
		alert('请至少选择一个要删除的模块');
		return;
	}
	if (!confirm('确定删除所选模块吗？')) {
		return;
	}
	gid.push({name:'act',value: 'delete'});
	$.getJSON('system/module.action', gid, function (rs) {
		if (rs.code == gid.length - 1) {
			fleshPage();
		} else {
			alert(rs.msg);
		}
	});
}
</script>
<div class="toolbar">
	<button type="button" onClick="module_add()"><span class="icon-plus"></span> 新建</button>
	<button type="button" onClick="module_edit()"><span class="icon-edit"></span> 编辑</button>
	<button type="button" onClick="module_delete()"><span class="icon-remove2"></span> 删除</button>
</div>
<div>
<div class="module-add"><div class="loadingext"><img src="/images/loading.gif" /></div></div>
</div>
<div class="modulelist">
  <table class="tablestyle1">
  <thead>
    <tr class="thead">
      <th class="thcheckbox"><input type="checkbox" onClick="cbchange(this,'.modulelist input[name=id]')" /></th>
      <th class="thid">编号</th>
      <th>名称</th>
      <th>扩展类型</th>
      <th>位置</th>
      <th class="thdate">创建日期</th>
    </tr>
    </thead>
    <tbody>
    <#list rslist.module as list>
    <tr>
      <td><input type="checkbox" name="id" value="${list._id}" /></td>
      <td>${list._id}</td>
      <td><span onClick="goPage('system/module.action?act=edit&id=${list._id}','.main')" class="mtitle">${list.title}</span></td>
      <td>${list.extension.name!"未知类型"}</td>
      <td>${list.position}</td>
      <td>${list.updated?date}</td>
    </tr>
    </#list>
    </tbody>
  </table>
	<@sys.pageList page=rslist />
</div>